home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / os2 / mouspd.zip / MOUSPEED.C < prev    next >
Text File  |  1995-03-24  |  4KB  |  133 lines

  1.  /*
  2.   * This program uses a semi-undefined mouse driver ioctl to change
  3.   * the dynamic movement of that device.  I decided to try this after
  4.   * browsing the DDSK CDROM source code for the mouse device driver,
  5.   * where I saw this ioctl hidden away.  The structure that it uses
  6.   * is,  however, documented in bsesub.h.
  7.   *
  8.   * Note that this program uses the ioctl defines for the Get/Set
  9.   * "hotkey". It appears that these are no longer supported for that
  10.   * function,  and are instead used to get/set the threshold
  11.   * multiplier buffer.
  12.   *
  13.   * To change the mouse behavior of the OS/2 2.x PM desktop,  this
  14.   * program must be run from a vio window.  It is a sample program
  15.   * only,  with hard-coded values for the new multipliers.
  16.   *
  17.   * Peter Fitzsimmons, Thu  94-06-09
  18.   *
  19.   *
  20.   *
  21.   * Added some 'features':
  22.   * - commandline parameter 
  23.   * - syntax info.
  24.   * - showing old and new values
  25.   *
  26.   * Works also with OS/2 WARP
  27.   *
  28.   * Andreas Just  March 1995
  29.   *
  30.   */
  31.  
  32.  
  33.  //  ibm cset++:  icc /Ssem /Kb mou.c
  34.  //               (use /Rn to make exe smaller)
  35.  
  36.  #define INCL_DOS
  37.  #define INCL_NOPMAPI
  38.  #define INCL_DOSDEVIOCTL
  39.  #define INCL_MOU
  40.  #include <os2.h>
  41.  #include <stdio.h>
  42.  #include <io.h>
  43.  #include <fcntl.h>
  44.  #include <assert.h>
  45.  #include <string.h>
  46.  #include <stdlib.h>
  47.  
  48.  
  49. int main(int argc, char **argv)
  50.  {
  51.      int h;
  52.      APIRET rc;
  53.      ULONG ulParmLen;
  54.      ULONG ulDataLen;
  55.      THRESHOLD buf, new;
  56.  
  57.      h = open("/dev/MOUSE$", O_RDWR);
  58.      if (h == -1) {
  59.          printf("Mouse not installed!\n");
  60.          exit(1);
  61.      }
  62.  
  63.      memset(&buf, 0, sizeof(buf));
  64.      buf.Length = sizeof(buf);
  65.      ulParmLen  = 0;
  66.      ulDataLen  = sizeof(buf);
  67.  
  68.      rc = DosDevIOCtl(h, IOCTL_POINTINGDEVICE,
  69.                       MOU_GETHOTKEYBUTTON,
  70.                       NULL, 0, &ulParmLen, &buf,
  71.                       sizeof(buf), &ulDataLen);
  72.  
  73.      if (rc)
  74.       {
  75.        printf("sys%04u: get ioctl failed\n", rc);
  76.        exit(1);
  77.       }
  78.      else  memcpy(&new, &buf, sizeof(buf));
  79.  
  80.  
  81.      if (argc < 5)
  82.       {
  83.        printf("\n-------- NO / NOT ENOUGH COMMANDLINE PARAMETERS - USING DEFAULT VALUES ---------\n\n");
  84.        printf("Syntax may be:\t MOUSPEED <a> <b> <c> <d>\n");
  85.        printf("\t\t <a> = First movement level   <b> = First level multiplier\n");
  86.        printf("\t\t <c> = Second movement level  <d> = Second level multiplier\n\n");
  87.        printf("Sample:\t\t MOUSPEED 3 2 20 4     \"sets slow values\"\n");
  88.        printf("       \t\t MOUSPEED 5 2 10 5     \"sets faster values\"\n");
  89.        printf("--------------------------------------------------------------------------------\n\n");
  90.  
  91.        // set default values:
  92.        new.Level1   = 5;
  93.        new.Lev1Mult = 2;
  94.        new.Level2   = 10;
  95.        new.lev2Mult = 5;
  96.       }
  97.      else
  98.       {
  99.        // get commandline values
  100.        *argv++; new.Level1   = atoi(*argv);
  101.        *argv++; new.Lev1Mult = atoi(*argv);
  102.        *argv++; new.Level2   = atoi(*argv);
  103.        *argv++; new.lev2Mult = atoi(*argv);
  104.       }
  105.  
  106.      printf("Old values:\t Level1    = %3d First movement level   \n", buf.Level1);
  107.      printf("\t\t Lev1Mult  = %3d First level multiplier \n", buf.Lev1Mult);
  108.      printf("\t\t Level2    = %3d Second movement level  \n", buf.Level2);
  109.      printf("\t\t lev2Mult  = %3d Second level multiplier\n", buf.lev2Mult);
  110.  
  111.      ulParmLen = sizeof(new);
  112.      ulDataLen = 0;
  113.  
  114.      rc = DosDevIOCtl(h, IOCTL_POINTINGDEVICE,
  115.                       MOU_SETHOTKEYBUTTON,
  116.                       &new, sizeof(new), &ulParmLen,
  117.                       NULL, 0, &ulDataLen);
  118.      if (rc) 
  119.       {
  120.        printf("sys%04u: set ioctl failed\n", rc);
  121.        exit(1);
  122.       }
  123.  
  124.      printf("New values:\t Level1    = %3d First movement level   \n", new.Level1);
  125.      printf("\t\t Lev1Mult  = %3d First level multiplier \n", new.Lev1Mult);
  126.      printf("\t\t Level2    = %3d Second movement level  \n", new.Level2);
  127.      printf("\t\t lev2Mult  = %3d Second level multiplier\n", new.lev2Mult);
  128.  
  129.      close(h);
  130.      return 0;
  131.  }
  132.  
  133.